import {ElMessageBox, ElTooltip} from 'element-plus'

type useElMessageBox = {
    <T extends import('element-plus').ElMessageBoxOptions>(options: T, callback: (result: { status: string }) => void): void
}
export const useElMessageBox: useElMessageBox = (options, callback) => {
    const {message, title} = unref(options)
    ElMessageBox.confirm(`${message ? message : 'proxy will permanently delete the file. Continue?'}`, `${title ? title : 'Warning'}`, {...options}).then((): void => {
        nextTick((): void => {
            callback({status: 'success'})
        })
    }).catch((): void => {
        nextTick((): void => {
            callback({status: 'fail'})
        })
    })
}

const useElTooltip: import("vue").DefineComponent = defineComponent({
    name: 'useElTooltip',
    components: {ElTooltip},
    setup(_: Record<string, any>, {attrs, slots}){
    const {effect = 'dark', trigger = 'hover', content = '', placement = 'top'} = unref(attrs as Record<string,any>)
    return (): JSX.Element => (
        <ElTooltip
            effect={effect}
            trigger={trigger}
            content={content}
            placement={placement}
        >
            {slots.default?.()}
        </ElTooltip>
    )
}
})
export default useElTooltip
